import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/home/Home'
//路由懒加载方式
const Home = () => import('../views/home/Home')
const Category = () => import('../views/category/Category')
import ShopCat from '../views/shopcart/ShopCart'
import Profile from '../views/profile/Profile'
//商品详情页
const GoodItem = () =>import('@/views/home/detail/GoodItem')
// 大屏页面
const MyPage1 = () => import('../views/datapage/MyPage1')
const Page2 = ()=>import('@/views/datapage/Page2')


Vue.use(VueRouter)
// 重定向路由
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

const routes = [
  {
    path: '',
    redirect: '/home'
  },
  // 首页
  {
    path: '/home',
    component: Home,
  },
  // 商品详情页
  {
    name:'/detail',
    path: '/detail',
    component: GoodItem
  },
  {
    path: '/category',
    component: Category
  },
  {
    path: '/shopcat',
    component: ShopCat
  },
  {
    path: '/profile',
    component: Profile
  },
  // 大屏
  {
    name:'/datapage',
    path: '/datapage',
    component: MyPage1,
    // children:[
    //   {path:'',component:''},
    // ]
  },
  {
    name:'/page2',
    path: '/page2',
    component: Page2
  },
  // 数字征迁系统
  {
    name:'/homepage',
    path: '/homepage',//首页
    component: () =>import('@/views/datapage/HomePage')
  },
  {
    name:'/workcenter',
    path: '/workcenter',//新建办件
    component: () =>import('@/views/datapage/workcenter/NewOffice')
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  components: {
    Home,
    Category,
    ShopCat,
    Profile,
    MyPage1
  }
})

export default router
